/**
 * @param {number[]} nums
 * @return {boolean}
 */
var canJump = function(nums) {
  let max = nums[0];
  for(let i = 1; i < nums.length; i++) {
    if(max >= i) {
      max = Math.max(max, nums[i] + i);
    } else {
      return false;
    }
  }
  return true;
};
let nums = [2,3,1,1,4];
console.log(canJump(nums));
nums = [3,2,1,0,4];
console.log(canJump(nums));
